#include "chem.h"

using namespace std;

void run(string input);

int main() {

	string input;
	while (true) {
		input.clear();
		cout << "Input formula:\n> ";
		getline(cin, input);
		if (input == "exit" || input == "bye" || input == "exit()" || input == "bye()" || input == "quit" || input == "quit()") {
			break;
		}
		run(input);
	}
	return 0;
}
void run(string input) {
	try {
		cout << Parser(Lexer(input).tokenize()).parse() << endl << endl;
	} catch (exception e) {
		cerr << e.what() << endl << endl;
	}
}